Skip to main content

Full text of "dg :: fhp :: 19771020 Memo312 COBOL S-Language"

See other formats


+4444 4444444444444444444444444444444444444444444444444444444444444444 44444 44444+ 

i $ j>S^>S 

i S i> & 

3? 

i> $ a) b 

& 35 03 vD 

$ i $ $4 4 

$4$ 4 $ 4 4S4S 

I)£>Ek = jJu QuEuE=LkT DE V I CE=SLPii 1 
SEQ = b OPR I = 12/ LPP = 65 CPL = 8u CuPIE3=l L.iMiT = 4v 

CkEaTcO; 20-OCW7 l5:4b:^4 

tNuUtUtD; o-uFu-77 l4:?i:o6 
pPINIIimG: o-uEl- 77 1 4 : 3 i : U4 

PA |H=:pDUIMEi v lO:Mfc.MU$4lc!.LS 



$ 


S> 


$ & $ 3> $ 


$ 


$ 


3>$4 


& 


$$$*$ 


& 


3>$i 




$ 


$4$ 


a>$ 




$ 


sb $ 




$ $ 


S vD S & 


a> 


$& 


$ $ 




$ 




$ & 


$ 


$ 


3> 4> 


& 


S $ 


& & 


$ 


4 4 


JR 




<R 


4? 


3> 3> 


a> 


$i£$3> 


4) $ 


a> 


$ <5 


$ i* 


i>Sb 


& 


S* 




5, 


5 $S> 


4) 


$ 


$ 


4) 




$ % 


& & 


5 


& 


3> 




35 


4) 


4 


& 


$ 


& 


& 


$ $ 


fc$4S 


$ $ 


a 


S 


4> $ 


$ 


4) 4? 


i 


$ 






& 


*$a> 


$ 


3>$3> 


4 $ 4 $ a> 


$a>$3>$ 


$ 


* * S * S 


$&$ 



+444444444444444444444444444444^4444 4444444444 44 "a444444444444444<+«4« +444444444+ 



AOS XLPT REV 01.00 




To 



Y'All 



From: John Pilat, Michael Richmond 

Subject: CuRuL S-Languaae, 1977 

Date: BU/Uct//7 Memo No. 3i? 

Aost ract : 

This memo describes the CuBOL S-Language. it supports J.9M o7u and 
Eclipse CUBuL data types, as well as the ANbI CUBuL standard. 



1 Data Types 

the data types supported by this COdOL s-languaae include 
those mandated oy the ANSI (ly74) standard, as well as those 
extensions offered oy ItiM 370 and the ECLlPSt., FxcePt for some 
minor storage allocation differences, tne extensions offered by 
both of these potential "market targets" are identical. bhould it 
become desirable (or necessary because of time constraints) this 
s-languaae can De striDpea of support for these extensions, witnout 
effect on the A w S i core, Dy deleting most instructions contain ina 
the word "RiNaRY" and all instructions containina the word 
"FluATlNG" . 



1.1 Data Type Considerations Masked by the compiler 

Some aspects of uOoOL "typeness" will oe removed by the CuBuL 
compiler, and will be realized with explicit instructions or 
through storage allocation policy. These include: 

a) Source operations requiring scaling or decimal Point 

alignment. Ihe compiler will generate exnlicit instructions 
to alian or scale operands. 

b) The determination of radix ana the concornmitant neeo for 

convers i on (s ) in operations. while tnis does have the 

effect of proliferating the number of instructions, it 
allows the IBM/ECLlPSt extensions to be separated easily 
from the remaining instructions and does not require a slow 
secondary decode for programs which use only ANbI stanuard 
t ypes . 

c) The need for editing, if any. The compiler will generate 

explicit edit instructions. 




Memo no. 3l2 
£0/ Oct/7 7 
page 2 



d) Synchronization and alignment. these are matters of 
storage allocation policy. 



1.2 Non-numeric Data 



1.2.1 ASCII as the NATIVE Character Set 

This CUBuL s-language supports A 5 CII as the NATiVt character 
set. Character translation instructions are included to deal with 
the alternate character set features of CUBUL. 



1.2.2 EBCDIC 

Support of EBCDIC may oe required at all levels of commercial 
software. The levei of support required is something that must be 
decided at the product planning level before EBCDIC support (oeyond 
the normal translation instructions) can be defined for a CuBUL 
s-1 anguage. 



1.3 Numeric Data 

CObOl defines a data item to be numeric if its picture con- 
sists only of the characters 9 # S # V # and P . Numeric data items 
may be combined freely in arithmetic statements. A distinction is 
made between data representations which must oe in standard format 
(USAGt IS DISPLAY) ano those which may be in i mo ] e mentor-defined 
formats (USAGt IS COMpU 1 A HONaL ) . 



1.3.1 USAuE IS DISPLAY 

All non-numeric data is USAGE iS DISPLAY. Numeric data can 
also be of this form# which requires that the internal reoresenta- 
tion be character-oriented decimal digits. The programmer can 
control the existence and location of an operational sign within a 
numeric DiSPLAY item. In all cases# the soace character is a valid 
substitute for the character zero. 




Memo no. 3i? 
<20/0ct/7/ 
page 3 



1.3. 1.1 Unsi qned 

This representation is aenerated wren a data item is described 
by a picture whicn does not contain the operational sign designator 
S. The numeric value is represented as a string of tne characters 



1.3. 1.2 Separate o i g n Lead ina/Trai ling 

This is the standard interchange representation for signed 
data. 1 he sign is either ' + ' or and is tne first/last charac- 

ter position of the data fielu. I he digit values are as above? 

'0' . . '9' . 



1.3. 1.3 Overpunched Siqn Leadi ng/Trai I i no 

in this representation? the first/last character position of 
the data field implies both a digit and an operational sign. ihis 
encoding is a de facto standard. It is presented herewith along 
with the tRCOiC encoding for comparison. Note that an ASC I i /cBcD IC 
character translation on a character decimal field performs the 
correct mapping. 



decimal 

Digit 


ASCII 

+ 




ASCII 




ASCII 

unsigned 


EbCu I C 

+ 


EdCOTC 


EoCuIo 
unsi gned 


1 0 I 


7 R 


1 


70 


1 


bO 1 


CU 


1 u0 


1 F u 


1 1 1 


41 


1 


51 


f 


31 1 


Cl 


1 ol 


1 F 1 


1 2 1 


4? 


1 


56 


1 


32 1 


C 2 


1 02 


1 F d 


1 3 1 


43 


1 


53 


i 


33 1 


C 3 


1 03 


! Fp 


1 A | 


44 


1 


54 


i 


34 1 


C 4 


1 04 


1 Fg 


1 5 1 


45 


1 


5b 


i 


35 1 


Cb 


1 05 


1 Fb 


1 6 1 


46 


1 


5o 


i 


36 1 


Cb 


1 06 


1 F 0 


1 7 1 


47 


1 


57 


i 


37 l 


C / 


i 07 


1 F, 


1 8 i 


48 


1 


56 


i 


S8 1 


Co 


1 08 


1 Fo 


1 9 i 


49 


1 


5G 


i 


39 1 


C 9 


1 09 


1 F 9 






Call table 


entries 


i n hexadec i mal ) 





1.3.2 USAGE IS COMPUTATIONAL Data 

The COBOL standard requires no Particular representation for 
COMPUTATIONAL data. in the interest of ECLlPSt/IBH compatibility 




Memo no. 3l2 
2 O/Oct/7 / 
page 4 



we have made the bindings presented below. 



1.3. 2.1 COMPUTATIONAL 

Ihese data items will be represented as signed, two's comple- 
ment binary inteqers, sized 8, 16, 24, 32, 40, 48, 36, anu o4 bits. 
The compiler will oenerate M AGwI|UoE instructions as needed to 
banal e unsigned binary aata (i.e., the interpreter need not worry 
about it). 



1.3. 2. 2 COMPUTATIONAL-! and CoMPUJA TIuNAL-2 

COMPoTaTI n ry A L — 1 data items will be 32 bit system floating 
point. COMPIJT A i I ONAL-2 data items will be o4 bit system floating 
point. Note that the interpreter must pe prepared to handle 
operations on mixes of the two precisions. 



1 .3.2.3 CUMPU T A T 1 0 N A L - 3 

COMPOTATI OoAL-3 aata items will be reoresented as packed 
dec i ma 1 . 



1.4 Name Table tntries 

The COdOL s-lanquage makes extensive use of namespace addres- 
sing features. All CuBOL subscripting ana indexing can be realized 
directly in the name table. IbM's extension which allows more than 
one dimension of an array to vary in size based on a run time value 
(which makes conversion of some IuM COdOl programs difficult on 
many systems) may also be realized directly. 



1.4.1 Starting Address ana Fetch direction 

All CObOL data will be addressed from the leftmost (i.e., low 
address) bit and be fetched to the right. ^hile it rrnqnt appear 
that numeric operands snould be addressed from the rightmost bit* 
this is not the case. First, the rightmost bit does not correspond 
to the low oraer digit (the address of start of the right most 
digit is seven less than the address of the rightmost bit). More 
importantly, an item addressed from the right would require another 
name table entry in order to be moved without regard to its type. 




i v 1emo no. 3 i 2 
b0/0ct/7/ 
page 5 



1.4.2 Length 

The length field in the name table contains an entity's bit 
length. The LObOL s-language uses entity length to distinguish 
between some source language data types. Single ana double preci- 
sion floating point (CUMPU I A TIuNAL-1 and CuMPUTAl I uNaL- 2 J are 
distinguished between each other by 32 or 64 in the length field. 
Size distinctions specified in a picture are also (obviously) 
reflected in the lenath field. 



1.4.3 Type 

The LOBOL s-language uses the name table type field to distin- 
guish among CuBuL's cornucopia of decimal data types. Note that of 
tnese seven types, only packed decimal is non-s t anda ru 1 The 
interpreter need only examine tne type field when an operand* is 
numeric decimal (something is numeric decimal if the opcooe says it 
is). The encoding of the four bit type field is as follows: 



0 U 0 0 : Packed decimal, unsigned. 
000 1 : Packed decimal, signed. 



0o 1 o : 


Character 


dec i ma 1 , 


unsigned 


• 








0011: 


Character 


decimal , 


s i gn 


i s 


separate 


and 


1 eaoi ng. 


OlOo: 


Character 


dec i ma 1 , 


s i gn 


i s 


separate 


and 


t r a i 1 i ng . 


0101: 


Character 


decimal , 


si gn 


i s 


overpunchea 


ana 


1 eadi ng. 


01 lu: 


Character 


decimal , 


s i gn 


i s 


overpunched 


ana 


trailing. 



The decimal operations are defined to accept any of these decimal 
formats. Note that when the interpreter stores a sianeo value (be 
it decimal, floating or binary) into a decimal datum wnose type 
field indicates "unsigned", only the magnitude of the value is 
stored. 

1.5 Instructions (100) 

|he notation used to describe instructions is as follows: 

Angle brackets < > enclose operands which are names. For 
example, <source> is the name (index into the name table) 




Memo no. 3i2 
20/Qct /I i 
page h 



of the source operand. 

Equal signs = = enclose operands which are literals 
offsets. For example, =pc = designates an offset from 
program counter. 



or 

the 




Memo no. 3i? 
c0/0ct/7/ 
page 7 



1.5.1 Moves ( 4 ) 



* MU\/E_CHaRaC I EKS <sou rc e> , <de s t i n a t i on > 

The lengths ot the operands as specified in the name table 
need not be equal. It the length of the source length 
exceeds the length of the destination* only "destination 
length" bits are moved. If the length of the destination 
is greater than the length of trie source, tne excess 
destination bits are filled with aScIi blank. isote that 
the lengths of the operands will always be some multiple of 
eight. 

* MUVE_CHAPACTEkS_EuUAL <sou rce> , <des t i nat i on> 

Exactly " sou r ce_l engt h " bits are moved to the destination 
from the source. 

* MUVE_CHARAC TFkS_EDI I El) <source>, <dest i nat i on>, <pi cture> 

This instruction is described in terms of pointers to the 
source, destination and picture. These pointers are not 
Part of the macro state. One picture element exists for 
each eight bit character in the destination. |he picture 
is processed land its pointer bumped) in syncnrony with tne 
destination, tach pixel is eight bits. Its interpretation 
is as follows: 

OOOlnnnn: Iransfer "nnnn" characters from the 
source to the destination. Botn source and destin- 
ation pointers are bumped by "nnnn". If the source 
is exhausted, the source pointer is not bumpeu, and 
an ASCII blank is transferred. 

All others: The Pixel character is transferred to 
the destination anu the destination pointer is 
bumped oy one. 




Memo no. 3i? 
20/Oct /l 1 

page 8 



MOVb_CHARAC i'FkS_TKANSLft TEU 
<scurce>,<destination>,<trans)ate table> 

The translate table is a string of e i gh t-o i t elements. 
This move behaves exactly like M0vE_CrlAKACTtR3 except that 
as each character is fetched from the source strina, it is 
usea as an index into the translate table. The contents of 
the translate table at the indexed location are transferred 
to the destination. Note tnat if blank padding is 
required^ the blank pad must be translated as well. 




Memo no. 3l2 
20/n c t/7/ 
page 9 



1.5.2 Conversions (15) 



* A3S1GN_DEC IdAi |0_BIMARY <sou rce> , <dest i nat i on> 



* ASSiGN_oEt IMAj iO_FLOATINp <sou rce> , <oest i nat i on> 



* A3SIGl\i_uFL I M A i iO__DtClMAL <source>»<destination> 



* ASS 1 GN_b I N A k Y_Tu_DEC I M Al <source>f <dest i nat i on> 



* ASSiGiSl_dI nAk Y_,Tu_FLU A TI imG <sou rce> , <des t i nat i on> 



* ASSiGN_bIi't!AKY_TU_Dli\iAr<Y < sou re e> t <des t i na t i on> 



* ASSiGrj_rLuAT lNG_TU_bIiMAKY <sou rce> , <des t i na t i on> 



* ASS 1 G is* L U A T I nG_T 0_DEC IMAL <source>,<dest mat jon> 



* ASSlGi^ELuAl ING_T0_r LuA | I nG <source>» <dest i nat i on> 



* A3SIGd_ MAbNiTUOE_bTNAHY < sou r c e> , <des t i na t i on> 



* DEC SC ALE_Lt p T =scale di f f = , <source> ( <dest i nat i on> 




Memo no. 3 12 
d 0/0ct/7/ 
page 10 



* DtClMAL_SLALE_RiGHT =scale aiff=r<source>r<destination> 



* RINARY_5CALt_UP_.BY_.10 =scale ai f f <source>r <uest i not i on> 



* B iNaR Y_5ChL t_D0^M_R Y_1 0 =scale ai ff=f<source>/<aestination> 



* DtCIMAt — RuUiyD =rounainp pos i t i on= , <sou rce> , <des t i nat i on> 




Memo no. 3i? 
<20/0ct/7/ 
page 11 



1.S.3 Numeric Eaitino Cl) 



Eun_WUMFRlL <source>» <tarpet> f <picture> 

The source is a decimal number which is edited into the 
target according to the oicture. The precise interpreta- 
tion of the picture is defineo oy an pPL procedure in tne 
apoenu i x . 




Memo no. 3i? 
20/0ct/7 i 
page 12 



1.5.4 Numeric Comparison branches (iOJ 

The numeric comparison branches compare two named 
values* or a single named value and zero* and hrancn to the 
indicated pc offset if the indicated comparison is true. 
The type of the sourceCs) and the comparison to oe per- 
formed is specified by each instruction's name. 

DEC 1M AL_C U m P AKE_EuU aL <sourcel>*<source2>* = pc = 



DECIMaL _CUMpAKE_NuT_EullAL <sourcel>*<sourceb>* = pc= 



DECIMAL _CuMp A KE_G HEATER <sou rc el>,< sou rce2>*=pe= 



DEC 1MaL._CuMP ARE_GHE ATER_OH_tQu Al <sourcel>,<source2>* =pc = 



BiNARY_.CDMPARt_t.QuAL <sourcel>*<source2>*=rc= 



Bi NAR Y_COi v iPARt_NO ) _EQO AL <source1>*<source?>*=Pc= 



B I N AR f _C0iMP ARt_uRt A |EH <sourcel>*<source2>*=oc = 



BiNARY_COMPARt_GRtAl Ek_uR_EuU AL <sourcel>,<source«t>*=pc = 



FLOAT INb_COMPARt_EQU AL <sourcet>*<source?>*=Pc= 



FLOAT iNb_LOMPARE_NOT_EQUAL <sourcel>*<source2>*=pc= 




Memo no. 3i2 
20/Oct /ll 
page 



* FlOaT iNb_LOMPAPt_GREA FEK <sou rce 1 > t <sou rce?> > = pc = 



* FLnATlNb_COMPARt_tREArER_.uR_F.QUAL <sou rce 1 > , <sou rce2> r -pc. 



* DEC i M aI Zt.RU_TEbT_EuUAL <source>,=pc = 



* DtC IM aL._ZlRu_TE5T_NuT_EQUaL < sou rce> , = pc = 



* DEC I MAL_ZERU_TEi>T_GKE ATtR <souPce>/=Pc : 



* OLC 1MaL_ZERu_ I EoT_GkE ATER_O n_tOUAL <source>»=pc- 



* DtC iMAL_ZERU_TEoT_LtGo <source>? =pc= 



* DEC IMAL_ZtRU_i Fi>T_LES$_uR_EuUAL <source>r =pc = 



* BINaR Y_ tERO_TtS I _EQ uAl <sou rce> r =pc = 



* B1NAR Y_ZEHO_TtS i _i'jOT_tOuAt <source>,=pc = 



* B 1 N AR Y_ZERO_Tt S | _GRtA I Fk <source>» -p c - 



* B X N AR Y_ZEHO_Tt S I _GRE A T Ek_OP_EQUAL <source>» =pc = 




Memo no. 3i? 
ZO/0ct/7/ 
page t <4 



B I N AP Y_ZEKO„_Tt S i _lE bS <sour'ce>f=pc = 



BIHaRY_ZFRO_TlS I - .LFShB_OR_c.QuAL <source>*=pc= 



FlOaT I Nb_ZFh0_T c. S I _t QU AL <source>» = pc= 



FLO ATi Nb_ZERO_Tt:S I .J^O T_tau Al <source>/=pc = 



F LOmTI NLj_ZEkO_T t S T_bRt A TEk <source>*=pc= 



FLHaT iNb_zFKO_T c S F _bRt A I Ek_uR_EuUaL <source>*=Pc = 



FLOAT J.Nb_ZEKO_TtS I _LEbS <source>f=Pc = 



FLOATINb_ZEKO_Tfc.S r„LESS_0R_„t QU A l <source>f =pc = 




the mo no. 3i2 
^O/Oct/7/ 
page lo 



l.S.S Mon-numeric Comparison branches (l2j 

Each non-numeric comparison executes a branch to the 
pc offset if its specified condition is true. Ihe compari- 
sons operate on eight bit characters in sequence from low 
to high aodress ( " 1 e f t - t o- r i qh t ) . Tne CH AP_CLA6S_Nu^tRIC 
and Ch AK_CLASS,_NO I'_NUMEKIC instructions also operate on 
oacKed 4-bit aigits (if indicated by the name table type 
field,). 

When more than one source is specifier they need not oe 
tne same lenqth. When the sources are not the same length/ 
the snorter source should be treated as if it were extended 
on the right by the ASCII blank character. Tne two-source 
comparisons effectively Proceed by comparing characters in 
corresponainq character positions until eitner a pair of 
unequal characters is encountered/ or until the end is 
reached/ whichever comes first. fhe first pair of unequal 
characters encountered is useo to determine if the condi- 
tion specified by each instruction's name is true. The 
sources are considered eoual if all pairs of characters 
compare equally through the last pair. 

ChAK_COlhPARt._t.Qu AL <sourcel>/<source2>/=pc = 



Cri AR_C0MPARt_NP 1 _EQU Ai_ <sourcel>/<source?>/=pc = 



CHAK_C0MP APt_CRt A 1 E K <sourcel>/<source?>/=PC = 



CHAK_COMPAPE_bREA | EK_ I RANSLATED 
<sourcel>/<source2>/<taole>/=pc= 

This instruction Dehaves like CHAR_CCJMP ARE_GkF AT cR except 
that the sources are translated through "table" as they are 
compared. 

ChAK_COMPARt_bRE A i EK_uR_EUUAL <sourcel>/<sourcec:>/=pc = 



ChAR_COmPARE_CRE ATEk__uR_EuUAL_TRA wSL A TEu 
<sourcei>/<source2>/<table>/=pc= 




Memo no. 3 1 2 
20/Oct/7/ 
page lo 




This instruction behaves like CtlAK_.COMPARL_.bPt A 1 ER_uR_EuUaL 
except that the sources are translated throuqh "table" as 
they are compared. 

* CHAR_CLASi)_ALPHABLTIC < sou re e > , =pc = 

The condition is true if all the characters in the source 
are in the set of ApCII characters "A" thru " L" ana the 
blank. Mote that lower case letters are not in tne seti 

* CHAK_CLAS5_i'j01_Ml.PHrtBc.TiC <sou rce> , =pc = 

This instruction is the inverse of CH aP_Cu A dS_ALPilAfciE 1 I L . 

* CnAR_CL AS5 _NUmFR I C <sou r ce> t = pc = 

The condition is true if all the characters in <source> 
contain the dipits U through V and if tne sign is valid. 
The sign is considerea valid if its existence and position 
are as described by the name table type field. ivote that 

the source must be checked A bits at a time if tne name 
table type field for <source> indicates "packed”. 

* CHAR_CLaS3_ImO 1_NUMERIC <source>» =pc = 

Tnis instruction is tne inverse of LHMR_CLAoS_Nu M tRjlC . 

* CtlAR_3PACLS <sou rce > , =pc = 

The condition is true it all the characters in the source 
are equal to aSLIi blank. 

* CriAK_ixO r_bPACtS <source>, = pc = 



This instruction is the inverse of CHaR_SPACES 




Memo no. 3i? 

dO/Oc t /7 / 
page 1 / 



1.S.6 Arithmetics ( E A j 

the type ot the souecets j and des t i na t i on l s ) for an 
arithmetic instruction is specified by the first part of 
the instruction's name. The operation to be Performed is 
specified by the second part of the instruction's name. 

If no preposition follows the first two parts ot the 
instruction's name* then the operation uses two sources 
distinct from the dest i nat i on (,<s ) . if a preposition ooes 
follow the instruction's name, then tne secono operand is 
specified by <cest i nat i on* or <quotient>. 

For SURlRAC! instructions, the first source is the subtra- 
hend and the second source (wnich might also be tne 
destination} is the minuend. 

For DIVlDt instructions the first source is the divisor and 
the second source (which might also be the quotient} is the 
dividend. Note that DIVlDt instructions produce two 
results, a quotient and a remainder. 

DEC IMAL_AuD <sourcel>,<source2>,<uestination> 



DEC IMhI SUB FPaCT <.sourcel>,<source?>,<destination> 



DECiMAL_MULTIbLY <sourcel>,<source2>,<destination> 



DECIMAL _D IV IDE <sourcel>,<source2>,<cuotient>,<remainoer> 



DECIMAL _AuD_TU <source>,<aestination> 



DECIMAl — SUBTRAC f_FRuM <source>,<destination> 



DtCIMML_MULllPLY_6Y <source>,<destination> 




Memo no. 3i2 
20/Oct/77 
page lb 



* DEC IMaL__DI VIDE_ iM I 0 <source>» <guot i ent>* <rema1 naer> 



* BINARY — A DU <sourcel>#<source2>r<destination> 



* BINAPY_SUtiTKACT < sou r c e 1 > , < sou re ed> , <aes t 1 n a t 1 on> 



* BINARY_MULT1PlY <sourcel>,<sourced>»<aest mat ion> 



* BiNARY_uI v IUE <sourcel>,<source£i>f<quotient>,<.remainder> 



* BINmR Y_AD u_i 0 <source>/ <dest i nat i on> 



* R 1NAP Y_SUbTKAcT_FKOM <source>/<destjnation> 



* BINaRY_J'1ULT IPlY_ 8 Y <source>, <dest i nat i on> 



* BINARY_Ul VIDE_lNTu <sou rc e > , <quo t l en t > f < rema i nde r> 



* FLO ATi Nl>_ADG <sou rce 1 > t <sou rce?> / <des t i na t i on> 



* FLOATlNG_i>UbTRACT <sourcei>f<sourcee!>/<destination> 



* FLOATiNG_MULTIPLY <sou rc e 1 > , <sou rc eL> , <des t i na t i on> 




Memo no. 3 jl? 
cfO / Oct/7/ 
page 1 9 



* Fl0aT1Nij„l) I V T DE <sou rce 1 > f <sou rced> t <quot i ent > , <rema i nde r> 



* FlOaT j.Nb_ADD_l 0 <source>»<destination> 



* FLOATlNG_i>UbTH ^CT_Fk0i*1 <s ou rc e> f <des t i n a t i on> 



* F l_ 0 A T i N G_M U l T I P l Y _R Y <source>,<dest i nat ion> 



* FL.OATi.MG_D I VlDE_TMu <sou rc e > , <quo t i en t > , < rema i nde r > 




Memo no. 3l? 
d0/0ct/7/ 
page ?U 



1.5.7 Size trror Handling (d) 

Many arithmetic and conversion operations can produce 
results which are too long to fit in the specified destina- 
tion (CuBUl lumps division by zero» overflow and underflow 
into this category). Explicit size error handling, when 
specified by the programmer, mandates tnat the destination 
field remain unchanged when a size error occurs. 

Ihe CObOL s-lanauaye therefore has two 1-bit size 
error flags which are part of process oata space. The 

first is called "UP_BaD". 0P_6aD is set to one by any 
operation which causes a size error. All operations except 
the conditional moves defined below are allowed to change 
the destination, even when a size error occurs. ror tnose 
instances where a size error is specified, the compiler 
will allocate a temporary as the destination, generating a 
checked assignment after the operation. The second size 
error flag is called "SIMJ^bAu". It is set to one it any 
operation in a statement incurs a size error. uP_BaD is 
always designated by name 0. S|K>r_bAu is always designated 
by name 1 . 

* BtGiN_.CHECKtD_.Sr A FEMEnT 

This operation sets Op^tiAu ana STpIT„_8aD to zero. 

* ChECKED__AdSiBI\!_uEC IMAl_I Q_DtC IP’AL <source>, <dest i nat i on> 

The action of this operation depends on the setting of 
0P_bAD: 



0P_dAD = 1. STmT_BAD is set to 1. 0P_t>Au is set 
to 0. 

0P__bAb = 0. if the source fits in the destination, 
then the source is assigned to the destination, as 
in the unchecked aSSI GN_DtC j,MaL_TU_UEC IMAl . if the 
source does not fit in the destination, SfM|_bAu is 
set to 1. Note that the condition "fits in the 
destination" may depend on the number of signifi- 
cant decimal digits in the source, and not just its 
1 engt h ! 



* 



CHECKtn_AbSIGN„BlNAPY_TO_bINAHY 
<source>,<! imi t>,<destination> 




Memo no. 
dO/Oct/7 / 
page 2 i 



The action of this operation depends on the setting of 
OP_dAD: 



0P_dAU = 1. STMT.BAD is set to 1. 0P_bAu is set 
to 0. 

0P_dAu = 0. If tne source fits in the destination, 
then the source is assigned to the destination, as 
in the unchecned ASSIbN_B i.NrtRY_Tn > _B.[HA D Y . If tne 
source ooes not fit in the destination, SlM'i_oAu is 
set to 1. ihe condition "fits in tne destination" 
is true if the magnitude of "source" does not 
exceed "limit". 



CHECKED _A SSiG[\i_FLUAT ! n G_TU._F10ATI hi G <source>, <dest i nat i on> 

The action of this operation depends on the setting of 
0P_b AD : 

0P_bAL> = 1. 3 TmT_BhD is set to 1. 0P__bAu is set 
to 0 . 

0P_dAu = U. An AoSiG.\i_PLuATlNG_Tu_PLuA | Ji\iG is 
executed. 

I F_N0_S I Zt_bRkOK =pc = 

If STMT_BAD is 0, a branch to tne pc offset is taken. 




Memo no. 31? 
?0/Oct/7/ 
page ?.d 



1.5.8 String instructions (i) 

ihe following instructions support the LOcOu S|RiNp, 
UNSfRiNu and INbPtCI statements. In all these 
instructions^ <source> and <dest i nat i on> name Character 
(i.e. length is a multiple of eiaht) data. The data named 
by <start>,<end> and <index> are binary integers which 
"index" either the source or the destination. fhe value 
one designates the first character position, two the 
second, etc. Li.e. the strings are entity indexed). 

a MUV£_STRInG <sou rce> , <st a r t > , <end>, <des t i nat i on> , =pc= 

The characters in "source" from "start" through "end" are 
moved to "destination". if the numoer of characters to oe 
moved exceeds the space available in "destination", trunca- 
tion takes place, and a branch to the pc offset is 
executed. 

* MUVt_TO_SrPINb <source>, <uest 1 nat i on> , <s t a r t > , <eno> , =pc= 

All the characters in "source" are movea to that portion of 
"destination" bounded by "start" through "end". If the 
numoer of characters to be moved exceeds the space in the 
delimited destination, truncation takes place and a Drench 
to the pc offset is executed. 

* SCAN_bTK ING <source>,<start>,<end>,<index>,<del imi ter>,=pc= 



The characters in "source" from "start" through "end" are 
scanned for charactertsl in "delimiter". If the delimiter 
is not founo, "index" is set to the "end", plus j, , and a 
branch to the pc offset is executed. if a delimiter is 
found, "index" is set to the character position preceeoi no 
the start of the delimiter. s'siote if the delimiter contains 
more than one character, all the characters must occur in 
sequence in "source". 




memo no. 3i2 
^0/0ct/7 l 
page ?o 



1.5.R Miscellaneous (t>) 



* GO i 0 <po offset> 

This instruction causes replacement of the offset Dortion 
of the program counter oy "po offset". 

* r ’U_T0_0FFdET —pc — 

This instruction causes a branch to be t a k e n to the pc 
offset . 

The following two instructions are generated as a compli- 
mentary pair. jhe "ending adoress variable" is the same in 
both instructions. 

* Pt.RFOKM_THRu <ending address va r i ab 1 e > , -pc~ 

The address of the instruction following the pEr<FuRm_ I HkU 
is assigned to the enuino address variable; then a oranch 
is executed to the pc offset. 

* Ei\in_PLRFOKM <enoing address vari abl e> 

The current value of the ending address variable is 
fetched. The address of the instruction following the 
END_Pt.Rr ORM is stored in the endi na adoress variaole. A 
branch to the fetched ending address completes the execu- 
tion of this instruction. I he compiler must ensure that 
the initial value of the ending address variable is the 
address of the instruction following the tNd_PEh,FuRM . 

* CaLL <.procedure> 

This instruction invokes the common external call 

mechanism^ with no parameters. 

* CALI USING =n = , <p r ocedu re> ; <Pa r ame t e r- 1 > ... <paramet er-n> 

This instruction invokes the common externa] call 

mechanism; with "n" parameters. 




Memo no. 3x2 
20/0c t / 7 / 
page 2 <4 



Appendix- bPL description of EDI T_ nUmEkIl 



procedure edit_numeric (read on i y s: 

write only t: 
reao only p : 



numeric, 
a I pn anume r i c , 
d i c c u re ) i 



type picture is array fp i c t u r e_coun t e rl of oyte; 
picture_counter is 0..35; 

alphanumeric is array 1 1 a rge t_coun t e rl of byte; 
t arget_counter is 1..3u; 

numeric is any of the seven decimal dwarves; 
source.counter is 1..16? 

byte is bit d as 0 . . 2 5 b ; 



variable finished: 
negative: 
t r i qge rea : 



boo lean; 
bool ean ; 
bool ean; 



di gi t_suDSt i tute: byte; 

negat i ve_i nser t : byte; 

posi t i ve_i nsert : byte; 

si: sou rc e.coun t e r ; 

ti: target_counter; 

pi: p i c t u r e„coun t e r ; 



Memo no. 3x2 
20/ 0ct/7/ 
page 2t> 



function deri ve_opcode tread only pixel: oytej 
returns edit.opcooe; 



type edit.opcode is ( mo ve.nume r i c , 

move .numeric. suppressed* 

mnvp_numenc_f loatiny, 

insert .character, 

insert .character. suppressed* 

i nsert_s i gn* 

end_ f 1 oat i no, 

t)l ank_when_zeroi 

ena.edi t * 

set.suppressionr 

set.flaatina.insertsj ? 



beg i n 

select pixel<u:4> of 

case 1: return move_numeric; 

case 2../: return insert .character; 

case 8: return mo ve.nume r i c.supp ressea ? 

case 9 : return move. numer i c.f I oat i ng? 

case 10. .15: return i nse r t .c n a r ac t e r.supp r esseu ? 

case 0: select p i x e 1 < 4 : 4 > of 

case 0: return set.suppress i on * 
case 1: return set.floating. inserts? 
case 2: return end.f 1 oat i ng? 

case 3: return insert.sign; 
case 4: return b 1 ank.when.zero* 

case S: return end.edit? 

otherwise: nothing; 

end select? 

end select? 



end function der i ve.opcode ? 




demo no. 3 i 2 
^O/Oct/7 i 
page ?. o 



procedure exec_pixei 


(read 


on | y 


pixel : 


byte) 


inherits 


(read 


write 


t r i ggereo: 


doo 1 ean , 




read 


on | y 


neyat i ve ; 


ooo lean. 




write 


only 


finished: 


doo lean. 




read 


write 


di gi t_ sub st i tute: 


byte. 




read 


write 


negative_insert: 


byte, 




reau 


write 


pos i t i ve_i nse r t : 


oyte;? 



variaDle cc: 
sc : 
z : 



bv t e ; 
byte; 
bool ean ; 



7 . working character 
7 . scratch character 
% is source digit zero.' 



begin 



select der i ve_ opcode (p i xe 1 ) of 



case move_numeric: 

times pixe1<^:^> repeat 

get_ai gi t_f rom_source (cc» z); 
triggered := triggered or not z? 
put_character_into_target (cc); 

end times; 



case move_numeri c_ suppressed: 

times pi xel <4:4> repeat 

get_ui gi t_f rom_source (cc, z); 
if z and not triggered 

then cc := di gi t_suDSt i tute; 
end if; 

triggered := triggered or not z! 
put_character_i nto„target (cc); 



end times; 




Memo no. 3l2 
dO/Oct/7/ 
page ?/ 



case nove_numeric_f loating: 

times nixel<4:4> repeat 

get_di gi t_f rom. source (ccr z); 
if not t r i gqe r ed 

then if z then cc := di gi t_suost i tutei 
else if negat 1 ve 

then sc := negat i ve_i nsert * 
else sc := pos i t i ve„i nsert ? 
end 1 f ; 

pu t_c Ha r ac t e r_ i n t o_t arget (sc); 

ena if; 

end if; 

triggered := triggered or not &} 
put_character_i nto_target (cc); 

end times; 



case insert_ char; 

cc ;= pi xel <1 ;7>; 

put _c ha r ac t e r_i n t o_t a roe t (cc); 



case i nsert_char_suPpr , esseo: 

if t r i qgered 

then cc := pi xel <1 ;7>; 
else cc ;= diai t_subst i tute? 
end if? 

du t _c na rac t e r_i n t o_t a rget (cc) ; 



case insert_sign; 

qet_nex t_pi xe 1 (sc); 

get_next_pi xe I (cc); 
if negative then cc := sc; end if; 
put_cnaracter_i nto_target (cc); 




Memo no. 3l2 
20/0ct /ll 
page ?o 



case end _d rifting: 



if t r i ggered 

then nothinq; 
else if negat i ve 

then cc := neqat i ve_i nse r t ; 
else cc := pos i t 1 ve_i nsert ; 
end if* 

nut_character_i nto_tarqet (cc); 



end if; 



case b 1 ank_when_z e ro : 

if not triggered then bl ank_target J end if; 
finished := true; 



case end_ed i t : 

finished : = true; 



case set _supp ress i on ; 

pet_next_pixel (digit ..substitute). 



case set _floatmg_ insertions: 

get _n ext ..pixel (negative., insertion), 
oet..next_pi xel (positive.. insertion); 



end select; 



return; 



end procedure exec_pixe! 




Memo no. 3x2 
d<VOc t / 7 / 
page 29 



begi n 



% 

% 

% 

% 

% 



X 

% 

MAIN LlNt tDIT CUHt % 

% 

% 



finished := false; 
negative := i s_negat i ve t s ) ; 
t r i gaered ; = false; 

di pi t_ suhst i tute : = asc 1 I_space; 
negat i ve_i nsert i on ;= A$c i I_m i nus ; 
pos i t i ve_i nsert i on := ASCII_space; 

si ; = 1 ; 

t i : = 1 ; 
pi : = 0 ; 



get _nex t_pi xel (target _aigitsj; 
repeat 

get_next_pi xel (ccj; 
ex ec_p i xe 1 ( cc ) ; 

if finished then return; end if; 
end repeat; 



end procedure edi t_numer i c ;